<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>系统基础数据维护</title>
    <jsp:include page="/include/common.jsp" />
    <script type="text/javascript" src="<c:url value="/resources/lib/jquery/plugin/jquery.form.min.js" />"></script>
    <script type="text/javascript" src="<c:url value="/resources/js/verify.js" />"></script>
    <script type="text/javascript">

        $(document).ready(function(){
            $('#listObject').datagrid({
                url:'<c:url value="/web/admin/sysConfig/listJson.json" />',
                title:'系统数据维护',
                singleSelect:false,
                fit:true,
                fitColumns:true,
                toolbar:'#tbSystemUser',
                rownumbers:true,
                pagination:true,
                pageSize: 20,
                selectOnCheck: true,
                checkOnSelect: true,
                columns:[[
//                    {field:'ck',checkbox:true},
                    {field:'id',title:'主键编号',align:'center'},
                    {field:'createTime',title:'创建时间',align:'center'},
                    {field:'distance',title:'任务距离',align:'center'},
                    {field:'edit',title:'操作',align:'center',formatter:function(val,row){
                        var editUrl = "<c:url value="/web/admin/sysConfig/edit.action?id=" />" + row.id;
                        var detail = "<c:url value="/web/admin/sysConfig/detail.action?id=" />" + row.id;
                        var editBtn = '&nbsp;<a href="javascript:void(0)" onclick="openWindow(\'#wSystemUser\', \'' + editUrl + '\')">编辑</a>'+
                                '&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="openWindow(\'#wSystemUser\', \'' + detail + '\')">详情</a>';
                               // '&nbsp;|&nbsp;<a href="javascript:void(0)" onclick="delData('+row.id+')">删除</a>';

                        return editBtn;
                    }}
                ]]
               /* onLoadSuccess:function(data){
                    if(data){
                        $.each(data.rows, function(index, item){
                            console.log(item.id);
                        });
                    }
                }*/
            });

            formatPagination("listObject");

            vEasyUIUtil.createWindow("wSystemUser", {
                title: '新增/编辑',
                width:640,
                height:vSugar.getMaxWinHeight("mainPanel", 600),
                modal:true,
                maximized:true,
                closed:true,
                iconCls:'icon-save'
            });

        });

        /******************************* 数据操作 *******************************/

        function delData(id) {

            if(!isNaN(id)) {
                if(confirm("确认删除记录？")) {
                    $.post('<c:url value="/web/admin/sysConfig/delete.action"/>', {'id' : id}, function(data) {
                        if(data.status == 0) {
                            $("#wSystemUser").window('close');
                            $('#listObject').datagrid('reload');
                        }else {
                            $.messager.alert('错误提醒', '网络错误', 'error');
                        }
                    }, 'JSON');
                }
            }else {
                $.messager.alert('警告', '未找到编号', 'warning');
            }
        }


        function submitSearch(){
            var dgSystemOrder = $('#listObject');
            dgSystemOrder.datagrid('options').pageNumber = 1;
            dgSystemOrder.datagrid('getPager').pagination("options").pageNumber = 1;
            var param = {
                merchantName : $('#merchantName').val()
            };
            dgSystemOrder.datagrid({queryParams: param}, 'reload');
            formatPagination("listObject");
        }

        function clearSearch() {
            $('#merchantName').textbox('setValue', '');

            var listObject = $('#listObject');
            listObject.datagrid('options').pageNumber = 1;
            listObject.datagrid('getPager').pagination("options").pageNumber = 1;
            var param = {
            };
            $("#listObject").datagrid({queryParams: param}, 'reload');

        }

    </script>
</head>
<body class="easyui-layout">
<input>
    <div data-options="region:'center',border:false,style:{padding:'4px'}" class="mainPanel">
        <div id="tbSystemUser" class="toolBarPadding">

            <div style="float:left;">
                <form action="<c:url value="/web/admin/sysConfig/listJson.action"/>" method="post" >

                   <%-- <a href="javascript:void(0)" class="easyui-linkbutton v-align-middle" data-options="iconCls:'icon-add',plain:true"
                       onclick="openWindow('#wSystemUser', '<c:url value="/web/admin/sysConfig/edit.action" />')">新增&nbsp;</a>
--%>
                    <%--<span>公司名称：</span> <input class="easyui-textbox" id="merchantName" name="merchantName" size="10"/>--%>
                    <%--<a href="javascript:void(0)" class="easyui-linkbutton v-align-right"--%>
                       <%--data-options="iconCls:'icon-search',plain:true"--%>
                       <%--onclick="submitSearch()">搜索&nbsp;</a>--%>
                    <%--<a href="javascript:void(0)" class="easyui-linkbutton v-align-right"--%>
                       <%--data-options="iconCls:'icon-clear',plain:true"--%>
                       <%--onclick="clearSearch()">清空&nbsp;</a>--%>
                </form>
            </div>
            <div style="float:right;">
            </div>
            <div style="clear:both;"></div>
        </div>
        <table id="listObject"></table>
    </div>

</body>
</html>